@inherits Blazorise.Offcanvas
@using System.Text;
<CascadingValue Value="@this" IsFixed>
    <CascadingValue Value="@State">
        <div @ref="@ElementRef" id="@ElementId" class="@ClassNames" style="@StyleNames" role="dialog" @attributes="@Attributes">
            @if ( ShowBackdrop && BackdropVisible )
            {
                <_OffcanvasBackdrop Animated="@Animated" AnimationDuration="@AnimationDuration" />
            }
            <div tabindex="0" aria-hidden="true" data-sentinel="start" style="width: 0px; height: 0px; overflow: hidden; outline: none; position: absolute;"></div>
            <div class="@GetClass()" style="@GetStyle()">
                <div class="ant-drawer-content">
                    <div class="ant-drawer-wrapper-body">
                        @ChildContent
                    </div>
                </div>
            </div>
        </div>
    </CascadingValue>
</CascadingValue>

@code {
    string GetClass()
    {
        var sb = new StringBuilder( "ant-drawer-content-wrapper" );

        if ( !State.Visible )
        {
            sb.Append( " ant-drawer-content-wrapper-hidden" );
        }

        return sb.ToString();
    }

    string GetStyle()
    {
        var sb = new StringBuilder( "" );

        if ( Placement == Placement.Top && State.Visible || Placement == Placement.Bottom && State.Visible )
        {
            sb.Append( " height: 378px;" );
        }

        if ( Placement == Placement.Start && State.Visible || Placement == Placement.End && State.Visible )
        {
            sb.Append( " width: 500px;" );
        }

        return sb.ToString();
    }
}
